package org.micode.demo.db.dao;

import org.micode.demo.db.domain.dto.SysRoleDTO;
import org.micode.libs.dao.base.BaseAllDao;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * 角色信息(sys_role) 实体类的Dao
 *
 * author: wutianbin
 */
@Mapper
public interface SysRoleDao extends BaseAllDao<SysRoleDTO> {

    // 非常规sql写这里--- xml 自动生成,不再手动在xml中写sql !!

    @Update("update sys_role set del_flag = 1," +
            " upd_user=#{updUser}, upd_prog=#{updProg}, upd_ip=#{updIp} " +
            " where role_id in (${ids})")
    Integer updateDeleteForIds(@Param("ids") String ids,
                               @Param("updUser") Long updUser,
                               @Param("updProg") String updProg,
                               @Param("updIp") String updIp);

    @Select("SELECT role_id FROM sys_role " +
            " WHERE del_flag = 0 " +
            "   and default_flag != 1 " +
            "   and role_id in (${roleIds})")
    @ResultType(Long.class)
    List<Long> listRoleIdNotDefault(@Param("roleIds") String roleIds);

}
